const path = require('path')

function resolve(dir) {
  return path.join(__dirname, dir)
}

module.exports = {
  publicPath: '/',
  assetsDir: 'static',
  outputDir: '../resources/templates',
  productionSourceMap: false,
  filenameHashing: true,
  chainWebpack: (config) => {
    config.resolve.alias
      //set第一个参数：设置的别名，第二个参数：设置的路径
      .set('@', resolve('src')) //根据目录的层级来决定，也可以自行设
      .set('@C', resolve('src/components'))
      .set('@V', resolve('src/views'))
      .set('@A', resolve('src/assets'))
      .set('@P', resolve('src/plugins'))
  },
  devServer: {
    proxy: {
      '/camera': {
        target: 'http://192.168.1.132:8089', //代理地址，这里设置的地址会代替axios中设置的baseURL
        changeOrigin: true, // 如果接口跨域，需要进行这个参数配置
        //ws: true, // proxy websockets
        //pathRewrite方法重写url
        pathRewrite: {
          '^/camera': '/camera'
          //pathRewrite: {'^/api': '/'} 重写之后url为 http://192.168.1.16:8085/xxxx
          //pathRewrite: {'^/api': '/api'} 重写之后url为 http://192.168.1.16:8085/api/xxxx
        }
      }
    }
  }
}
